Practical SharePoint 2010 Branding and Customization by Erik Swenson

Practical SharePoint 2010 Branding and Customization by Erik Swenson

Author:Erik Swenson [Swenson, Erik]
Language: eng
Format: epub, pdf
Publisher: Apress
Published: 2011-12-23T05:00:00+00:00


Figure 6-23. Creating a new module

Notice in Figure 6-24 the Solution Explorer window now includes your new module called Branding Files and a Feature named Feature1.

Figure 6-24. Newly created module and feature

Before going further, delete the Sample.txt file your module created. Now import the master page you created in SharePoint Designer (this file should be saved to your file system) by right-clicking on your module, selecting Add, and then selecting Existing Item. Instead of using the export feature from SharePoint Designer, it is recommended that you download it directly from the master page gallery by clicking on the document arrow, and choosing Send To download a copy. Saving the file this way will preserve the HTML formatting of the SharePoint master page. There have been some cases where the export feature in SharePoint designer messes up the formatting of the HTML.

You now need to change your module’s XML directives to handle deploying the master page correctly. If it’s not already open, open the Elements.xml file, and replace the markup so it’s in the format shown in Listing 6-16.

Listing 6-16. Master Page Deployment Code in elements.xml File.

<Module Name=" BrandingFiles" Url="_catalogs/masterpage" RootWebOnly="false">

<File Path=" BrandingFiles\custom_V4.master" Url="custom_V4.master"

Type="GhostableInLibrary" IgnoreIfAlreadyExists="true" >

<Property Name="Title" Value="Custom Master Page" />

<Property Name="ContentType"

Value="$Resources:cmscore,contenttype_masterpage_name;"></Property>

</File>

</Module>

Looking at Listing 6-16 above, the attribute Type=“GhostableInLibrary” indicates that the item has been added to the content database. The IgnoreIfAlreadyExists=”true” statement is used to provision the file without error even if the file already exists at the specified URL. The Url attribute of the module specifies where to store the file in the SharePoint content database. Lastly the Name=“ContentType” indicates the localized master page content type.

You’re also going to want to change the name of the Feature1 feature to a more appropriate name. If you double-click on the feature, you should also change the title and description (this is what appears in the SharePoint Feature Activation application pages). Also notice in Figure 6-25 the properties scope is set to Web, which means it will be activated in the Site Features. (You optionally could set it to Site, which means it would be activated for an entire Site Collection. We’re not covering themes here, but if you are also deploying a theme, you must select the Site scope.)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.